//
//  OrderCell.m
//  HubeiHotel
//
//  Created by LiBenCan on 17/11/20.
//  Copyright © 2017年 张露杰. All rights reserved.
//

#import "OrderCell.h"

#import "chooseBtnView.h"
@implementation OrderCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)loadCell:(NSDictionary *)dataDic isEditing:(BOOL)isHiden
{
    for (UIView *view in self.contentView.subviews) {
        [view removeFromSuperview];
    }
    
    //名称
    _nameLab = [UILabel new];
    _nameLab.textColor = TextBlack;
    _nameLab.font = [UIFont systemFontOfSize:17];
    _nameLab.text = dataDic[@"jdBusiness"][@"name"];
    _nameLab.numberOfLines = 0;
    [self.contentView  addSubview:_nameLab];
    [_nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(15*screenW_6);
        make.top.equalTo(self.contentView).offset(15*screenW_6);
        make.width.equalTo(@(SCREENW-100*screenW_6));
    }];
    
    //预约时间
    float titleWidth = [ToolViewVC getlabWidth:[NSString stringWithFormat:@"预约时间：%@",dataDic[@"scheduledTime"]] WithFont:14*screenW_6];
    _timeChooseLab = [[chooseBtnView alloc]initWithFrame:CGRectMake(15*screenW_6,0,titleWidth+30*screenW_6,25) Title:[NSString stringWithFormat:@"预约时间：%@",dataDic[@"scheduledTime"]] NomolImageV:@"Order_time_hui" SelectImageV:@"" IsSelect:NO];
    _timeChooseLab.titleLab.textColor = TextGray;
    [self.contentView addSubview:_timeChooseLab];
    [_timeChooseLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(15*screenW_6);
        make.top.equalTo(_nameLab.mas_bottom).offset(10*screenW_6);
        make.width.equalTo(@(titleWidth+30*screenW_6));
        make.height.equalTo(@(25));
    }];
    
    //删除按钮
    _deletBtn = [[chooseBtnView alloc]initWithFrame:CGRectMake(SCREENW-55*screenW_6,0,50*screenW_6,25) Title:@"删除" NomolImageV:@"Order_delete_hui"SelectImageV:@"" IsSelect:NO];
    _deletBtn.titleLab.textColor = TextRed;
    [self.contentView addSubview:_deletBtn];
    [_deletBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-10*screenW_6);
        make.top.equalTo(_timeChooseLab);
        make.width.equalTo(@(50*screenW_6));
        make.height.equalTo(@(25));
    }];
    [_deletBtn addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(delete)]];
    
    //画线
    _lineLab = [UILabel new];
    _lineLab.backgroundColor = LineColor;
    _lineLab.text = @" ";
    [self.contentView  addSubview:_lineLab];
    [_lineLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(0));
        make.right.equalTo(@0);
        make.height.equalTo(@1);
        make.top.equalTo(_deletBtn.mas_bottom).offset(10*screenW_6);
        make.bottom.equalTo(self.contentView).offset(0);
    }];
    
    _deletBtn.hidden = !isHiden;
    if (_deletBtn.hidden) {
        _deletBtn.userInteractionEnabled = YES;
    }
}

-(void)delete
{
    if (_block) {
        _block();
    }
}

@end
